<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        var add = function(x) {
            return function(y) {
                return x + y;
            };
        };

        var increment = add(1);
        var addTen = add(10);

        var a = increment(2);
        console.log(a);
        // 3

        var b = addTen(2);
        console.log(b);
        // 12
    </script>
</body>

</html>